from model import BaseModel, models


class Menus(BaseModel):
    name = models.CharField(max_length=64, unique=True, verbose_name="名称")
    icon = models.CharField(max_length=32, null=True, blank=True, verbose_name="菜单图标")
    path = models.CharField(max_length=128, null=True, blank=True, verbose_name="路径")
    type_choice = (
        (1, "按钮"),
        (2, "菜单"),
    )
    type = models.IntegerField(verbose_name="类型", choices=type_choice, default=1)
    method_choice = (
        (1, "GET"),
        (2, "POST"),
        (3, "DELETE"),
        (4, "PUT"),
        (5, "PATCH"),
    )
    method = models.IntegerField(verbose_name="请求类型", null=True, blank=True, choices=method_choice)
    api_path = models.CharField(max_length=128, null=True, blank=True, verbose_name="api路径")
    identical = models.CharField(max_length=128, null=True, blank=True, verbose_name="user:query格式")
    parent = models.ForeignKey(to="self", null=True, blank=True, on_delete=models.CASCADE)

    class Meta:
        db_table = 'menus'
        verbose_name = '菜单表'
        verbose_name_plural = verbose_name
